package org.nekperu15739.aboutme.persistencemodel.domain.implementation.i18n;

import java.io.Serializable;
import java.util.Date;

import javax.annotation.PreDestroy;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.PostPersist;
import javax.persistence.PostRemove;
import javax.persistence.PrePersist;
import javax.persistence.PreRemove;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nekperu15739.aboutme.persistencemodel.domain.abstracts.EntityAbstract;

@Entity
@Table(name = "language", schema = "i18n")
@NamedQuery(name = "Language.findByEmailAddress", query = "select u from Language u where u.language = ?1")
public class Language extends EntityAbstract<User, Short> implements Serializable {
	
	private final Log logger = LogFactory.getLog(getClass());

	private static final long serialVersionUID = 1L;
	private Short languageId;
	private String language;
	
	private User user;
	
	public Language() {
		super();
	}
	
	public Language(String language) {
		super();
		this.language = language;
	}

	public Language(Short languageId, String language) {
		super();
		this.languageId = languageId;
		this.language = language;
	}

	public Language(String language, String audUser, Date audTime) {
		super();
		this.language = language;
		this.audUser = audUser;
		this.audTime = audTime;
	}

	@Column
	public String getLanguage() {
		return language;
	}

	public void setLanguage(String language) {
		this.language = language;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(nullable=false, unique=true)
	public Short getLanguageId() {
		return languageId;
	}

	public void setLanguageId(Short languageId) {
		this.languageId = languageId;
	}

	@Override
	@Transient
	public Short getPrimaryKey() {
		return null;
	}

	

//	@CreatedDate
//	@LastModifiedDate
//	@DateTimeFormat(style="M-")
//	public Timestamp getAudTime() {
//		return audTime;
//	}
	
	

//	@OneToOne(mappedBy="language")

//	@Temporal(TemporalType.TIMESTAMP)
	@PreDestroy
	private void PreDestroy() {
		
	}

	@PrePersist
	private void PrePersist() {
		getLogger().info(this);
	}
	
	@PostPersist
	private void PostPersist() {
		getLogger().info(this);
	}
	
	
	@PreRemove
	private void PreRemove() {
		
	}
	
	@PostRemove
	private void PostRemove() {
		
	}
	
	@PreUpdate
	private void PreUpdate() {
		
	}

	@Transient
	public Log getLogger() {
		return logger;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	
//	@PostRemove
//	@PostPersist
//	@PostLoad
//	@PostUpdate
	
}
